package com.xuecheng.content.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xuecheng.content.model.po.TeachplanMedia;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 勾新杰
 * @since 2024-12-21
 */
public interface TeachplanMediaMapper extends BaseMapper<TeachplanMedia> {

    /**
     * 根据课程id查询课程计划媒资信息
     * @param courseId 课程id
     * @return 课程计划媒资信息
     */
    @Select("select * from xcplus0107_content.teachplan_media where course_id = #{courseId};")
    List<TeachplanMedia> selectByCourseId(Long courseId);

    /**
     * 根据课程id删除课程计划媒资信息
     * @param courseId 课程id
     */
    @Delete("delete from xcplus0107_content.teachplan_media where course_id = #{courseId};")
    void deleteByCourseId(Long courseId);

    /**
     * 根据课程计划id删除课程计划媒资信息
     * @param teachplanId 课程计划id
     */
    @Delete("delete from xcplus0107_content.teachplan_media where teachplan_id = #{teachplanId};")
    void deleteByTeachPlanId(Long teachplanId);

    /**
     * 根据课程计划id和媒资id删除课程计划媒资信息
     * @param teachPlanId 课程计划id
     * @param mediaId 媒资id
     */
    @Delete("delete from xcplus0107_content.teachplan_media where teachplan_id = #{teachPlanId} and media_id = #{mediaId};")
    void deleteByTeachPlanIdAndMediaId(@Param("teachPlanId") Long teachPlanId, @Param("mediaId") String mediaId);
}
